package com.ruoyi.quartz.task;

import com.ruoyi.common.constant.DicConstants;
import com.ruoyi.product.domain.StoreProduct;
import com.ruoyi.product.service.IStoreProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

/**
 * @author chengliang
 * @date 2022/2/28
 **/
@Component("productTask")
public class ProductTask {
    @Autowired
    private IStoreProductService productService;

    public void shelveDownTask(){
        List<StoreProduct> list = productService.selectNeedShelveDown();

        list.forEach(e->{
            Date date = new Date();
            e.setState(DicConstants.SYS_N.getCode());
            e.setOffautoTime(date);
            e.setOffTime(date);
            e.setOffUser(0L);
            e.setOffUserType(DicConstants.BUSINESS_Manager.getCode());
            productService.updateStoreProduct(e);
        });
    }
}
